package com.bcx.crm.spring.controller.thymeleaf;

import com.bcx.crm.mapper.templateTestMapper.SelectTemplateMapper;
import com.bcx.crm.plat.core.utils.SpringContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by ys on 2018/2/27.
 */
@Controller
@RequestMapping("/thymeleaf1")
public class thymeleaf1 {
    private static final Map<String,Object> map = new HashMap<>();
    @RequestMapping("/get")
    public ModelAndView getView(){
        ModelAndView mv = new ModelAndView("/crm/thymeleaf/practice/home.html");
        mv.addObject("viewName",new String[]{"/crm/thymeleaf/practice/home.html123"});
        map.put("rowId","row------Id");
        map.put("templateCode","template------code");
        mv.addObject("map",map);
        return mv;
    }
    @GetMapping("/getTemplateList")
    public ModelAndView getTemplateList(){
        ModelAndView mav = new ModelAndView("crm/thymeleaf/practice/docTemplate");
        List<String> list = new ArrayList<>();
//        list.add("aa28f5a1-55ce-4d0c-b4ee-021a74ae");
//        list.add("d3dfce81-e26c-4d75-90bd-4ffcd2d3");
//        list.add("dd47b10e-48ab-4d07-81fc-64913cb3");
        list.add("0f4c1261-177c-4f1a-94fa-0db96537");
        list.add("1709b4a9-be78-4e7b-a7e2-f52cad1f");
        list.add("18260121-821d-4a72-a15e-8b93077c");
        List<Map<String, Object>> listByRowIds = SpringContextHolder.getBean(SelectTemplateMapper.class).getListByRowIds(list);
        mav.addObject("listByRowIds",listByRowIds);
        return mav;
    }
    @GetMapping("/test1")
    public ModelAndView test1(){
        ModelAndView modelAndView = new ModelAndView("crm/thymeleaf/practice/includeTest.html");
        return modelAndView;
    }
}
